<?php
namespace App\Job;

use Cake\Queue\Job\Message;
use Cake\Queue\Job\JobInterface;
use Interop\Queue\Processor;
use Cake\ORM\TableRegistry;

class TestJob implements JobInterface
{
    public function execute(Message $message): ?string
    {
        // TODO: Implement execute() method.
        $title = $message->getArgument('title');
        $code = $message->getArgument('code');

        $tests = TableRegistry::getTableLocator()->get('Tests');
        $tests->query()
            ->insert(['title', 'code', 'date_time'])
            ->values(['title' => $title,
                'code' => $code,
                'date_time' => time()
            ])
            ->execute();

        return Processor::ACK;
    }
}
